#pragma once
#include <jsoncpp/json/json.h>

struct request
{
    int x;
    int y;
    char oper;
};

struct response
{
    int result;
    int code;
};

class Request
{
public:
    Request(int x, int y, char oper) : _x(x), _y(y), _oper(oper)
    {
    }
    bool Serialize(std::string *out)
    {
        Json::Value root;
        root["x"] = _x;
        root["y"] = _y;
        root["oper"] = _oper;

        Json::FastWriter writer;
        std::string s = writer.write(root);

        *out = s;
        return true;
    }
    int X()
    {
        return _x;
    }
    int Y()
    {
        return _y;
    }
    void Deserialize(const std::string &in)
    {
    }

    ~Request()
    {
    }
    char Oper()
    {
        return _oper;
    }
    void SetValue(int x, int y, char oper)
    {
        _x = x;
        _y = y;
        _oper = oper;
    }
private:
    int _x;
    int _y;
    char _oper;
};

class Response
{
public:
    Response()
    {
    }
    bool Serialize(std::string *out)
    {
    }
    void Deserialize(const std::string &in)
    {
    }
    ~Response()
    {
    }

public:
    int _result;
    int _code; // 0: success, 1: div zero 2. 非法操作
    std::string _desc;
};

class Factory
{
public:
    static std::shared_ptr<Request> BuildRequestDefault()
    {
        return std::make_shared<Request>();
    }
    static std::shared_ptr<Response> BuildResponseDefault()
    {
        return std::make_shared<Response>();
    }
};